package com.testmanager.testmananger.shuiyou.strCompare.service;

import com.testmanager.testmananger.shuiyou.strCompare.domain.SyCompareDetailResultEntity;
import com.testmanager.testmananger.shuiyou.strCompare.domain.SyCompareResultEntity;
import com.testmanager.testmananger.shuiyou.strCompare.respository.SyCompareDetailResultRepository;
import com.testmanager.testmananger.shuiyou.strCompare.respository.SyCompareResultRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class SyCompareResultService {

    @Autowired
    SyCompareResultRepository resultRepository;
    @Autowired
    SyCompareDetailResultRepository detailResultRepository;



    public ResponseEntity getResult(long taskId){

        log.info("getResult,taskid:{}",taskId);
        List<SyCompareResultEntity> results = resultRepository.findAllByCompareTaskidOrderByIdDesc(taskId);

        return ResponseEntity.ok(results);
    }


    public ResponseEntity getDetailResult(long resultId){

        log.info("getDetailResult,resultid:{}",resultId);

        List<SyCompareDetailResultEntity> allByResultId = detailResultRepository.findAllByResultId(resultId);
        return ResponseEntity.ok(allByResultId);

    }


    public ResponseEntity getAllResult(){
        log.info("getAllResult");

        List<SyCompareResultEntity> results = resultRepository.findAll();

        return ResponseEntity.ok(results);
    }



}
